#include "expsample.h"
#include "algorithm.h"

QHash<QString,double> PreScanResult::GetCnHalfs()
{
    return cnHalfs;
}
void PreScanResult::SetCnHalfs(QHash<QString,double> datas)
{
    cnHalfs =datas;
}

QHash<QString,double> MainScanResult::GetCnCals()
{
    return cnCals;
}
QHash<QString,double> MainScanResult::GetCpsCals()
{
    return cpsCals;
}
QHash<QString,double> MainScanResult::GetCpsJammings()
{
    return cpsJammings;
}
QHash<QString,double> MainScanResult::GetCpsInternals()
{
    return cpsInternals;
}
QHash<QString,double> MainScanResult::GetIsotopes()
{
    return isotopes;
}
QList<double> MainScanResult::GetRatios()
{
    return ratios;
}
void MainScanResult::SetCnCals(QHash<QString,double> datas)
{
   cnCals =datas;
}
void MainScanResult::SetCpsCals(QHash<QString,double> datas)
{
    cpsCals=datas;
}
void MainScanResult::SetCpsJammings(QHash<QString,double> datas)
{
    cpsJammings =datas;
}
void MainScanResult::SetCpsInternals(QHash<QString,double> datas)
{
    cpsInternals =datas;
}
void MainScanResult::SetIsotopes(QHash<QString,double> datas)
{
    isotopes =datas;
}
void MainScanResult::SetRatios(QList<double> datas)
{
    ratios=datas;
}
double MainScanResult::GetInternalCps(double x)
{
    double y=0;
    int count=ratios.count();
    for(int i=0;i<count;i++)
    {
       switch(i)
       {
       case 0:
           y+=ratios.at(0);
           break;
       case 1:
           y+=ratios.at(1)*x;
           break;
       case 2:
           y+=ratios.at(2)*x*x;
           break;
       case 3:
           y+=ratios.at(3)*x*x*x;
           break;
       case 4:
           y+=ratios.at(4)*x*x*x*x;
           break;
       }
    }
    return y;
}
//
ExpSample::ExpSample()
{

}

QList<SampleInfor> ExpSample::GetSampleInfors()
{
   return sampleInfors;
}
SampleInfor ExpSample::GetSampleInfor(int index)
{
   return sampleInfors.at(index);
}
bool ExpSample::SetSampleInfor(int index,SampleInfor infor)
{
    if(sampleInfors.count()<index+1) return false;
    sampleInfors[index]=infor;
    return true;
}
QList<SampleInfor>* ExpSample::GetSampleInforsPtr()
{
    return &sampleInfors;
}
SampleInfor* ExpSample::GetSampleInforPtr(int index)
{
    return &sampleInfors[index];
}
bool ExpSample::GetBlank(SampleInfor &sampleInfor)
{
    for(int i=0;i<sampleInfors.count();i++)
    {
        if(sampleInfors.at(i).sampleType=="空白")
        {
            sampleInfor=sampleInfors.at(i);
            return true;
        }
    }
    return false;
}

void ExpSample::SetExpPtr(Experiment* pExperiment)
{
    this->pExperiment=pExperiment;
}
int ExpSample::GetSampleCount()
{
    return sampleInfors.count();
}
void ExpSample::CalRatioss()
{

}

